package com.mes.basicdata.domain;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Lazy;
import com.mes.common.domain.BasicModel;

@Entity()
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name = "R_AGGREGATE_RESOURCE")
@BatchSize(size=30)
@Lazy(value=true)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ResourceAggregate extends BasicModel implements java.io.Serializable {
	
	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name="UNIQUEID",scale=0)
	private String uniqueId;
	
	@Column(name="AGGREGATE_RESOURCE")
	private String workCenterUid;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY,cascade=CascadeType.PERSIST)
	@JoinColumn(name="AGGREGATE_RESOURCE",insertable=false,updatable=false)
	private WorkCenter workCenter;
	
	@Column(name="SUB_RESOURCE")
	private String deviceUid;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY,cascade=CascadeType.PERSIST)
	@JoinColumn(name="SUB_RESOURCE",insertable=false,updatable=false)
	private Device device;
	
	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	public String getWorkCenterUid() {
		return workCenterUid;
	}

	public void setWorkCenterUid(String workCenterUid) {
		this.workCenterUid = workCenterUid;
	}

	public WorkCenter getWorkCenter() {
		return workCenter;
	}

	public void setWorkCenter(WorkCenter workCenter) {
		this.workCenter = workCenter;
	}

	public String getDeviceUid() {
		return deviceUid;
	}

	public void setDeviceUid(String deviceUid) {
		this.deviceUid = deviceUid;
	}

	public Device getDevice() {
		return device;
	}

	public void setDevice(Device device) {
		this.device = device;
	}

	@Override
	public String getUuid() {
		// TODO Auto-generated method stub
		return this.getUniqueId();
	}

	@Override
	public void setUuid(String uuid) {
		// TODO Auto-generated method stub
		this.setUniqueId(uuid);
	}
	
	

	
}
